<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>修改员工页面</h1>
<form action="">
  <input type="text" name="id" :value="emp.id" readonly>
  <input type="text" name="name" :value="emp.name">
  <input type="text" name="sal" :value="emp.sal">
  <input type="text" name="job" :value="emp.job">
  <input type="button" value="修改" @click="update()">
</form>
<!--引入CDN服务器的框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script>
  let v = new Vue({
    el:"form",
    data:{
      emp:{}
    },
    created:function (){
      let id = location.search.split("=")[1];
      axios.get("/selectById?id="+id).then(function (response){
        v.emp = response.data;
      })
    },
      methods:{
        update:function () {
            let data = new FormData(document.querySelector("form"));
            axios.post("/update",data).then(function () {
                alert("修改成功!");
                location.href="/list.html"
            })
        }
      }
  })
</script>
</body>
</html>